package com.swinginwind.flexutils.components
{
	/**
	 * @author jimmy
	 * @E-mail: swinginwind@gmail.com
	 * @version 1.0.0
	 * 创建时间：2013-5-9 下午4:44:48
	 * 
	 */
	import flash.display.Sprite;
	
	import mx.collections.ArrayCollection;
	import mx.controls.DataGrid;
	
	public class RowColorDataGrid extends DataGrid
	{
		public function RowColorDataGrid()
		{
			super();
		}
		
		override protected function drawRowBackground(s:Sprite, rowIndex:int, y:Number, height:Number, color:uint, dataIndex:int):void 
		{ 
			if(dataProvider is ArrayCollection)
			{
				
				var list:ArrayCollection = ArrayCollection(dataProvider); 
				if(dataIndex<list.length) 
				{ 
					var item:*=list[dataIndex]; 
					if(item && item.color != 0)
					{
						super.drawRowBackground(s,rowIndex,y,20,item.color,dataIndex); 
					}
					else
						super.drawRowBackground(s,rowIndex,y,20,color,dataIndex); 
				} 
				else
					super.drawRowBackground(s,rowIndex,y,20,color,dataIndex); 
				
			}
			else
			{
				super.drawRowBackground(s,rowIndex,y,20,color,dataIndex); 
			}
		} 
	}
}